/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.oneCommerce.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Aymen
 */
@Entity
@Table(name = "PHOTOS", catalog = "", schema = "AYMEN")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Photos.findAll", query = "SELECT p FROM Photos p"),
    @NamedQuery(name = "Photos.findByIdphoto", query = "SELECT p FROM Photos p WHERE p.idphoto = :idphoto"),
    @NamedQuery(name = "Photos.findByPhotopath", query = "SELECT p FROM Photos p WHERE p.photopath = :photopath"),
    @NamedQuery(name = "Photos.findByFilename", query = "SELECT p FROM Photos p WHERE p.filename = :filename")})
public class Photos implements Serializable {
    private static final long serialVersionUID = 1L;
    public static final String FIND_BY_IDPHOTO = "Photos.findByIdphoto";
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "IDPHOTO", nullable = false, precision = 22, scale = 0)
    @GeneratedValue(strategy= GenerationType.AUTO)
    private BigDecimal idphoto;
    
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "PHOTOPATH", nullable = false, length = 50)
    private String photopath;
    @Size(max = 50)
    @Column(name = "FILENAME", length = 50)
    private String filename;
    @JoinColumn(name = "IDITEM", referencedColumnName = "IDITEM", nullable = false)
    @ManyToOne(optional = false)
    private Item iditem;

    public Photos() {
    }

    public Photos(BigDecimal idphoto) {
        this.idphoto = idphoto;
    }

    public Photos(BigDecimal idphoto, String photopath) {
        this.idphoto = idphoto;
        this.photopath = photopath;
    }

    public BigDecimal getIdphoto() {
        return idphoto;
    }

    public void setIdphoto(BigDecimal idphoto) {
        this.idphoto = idphoto;
    }

    public String getPhotopath() {
        return photopath;
    }

    public void setPhotopath(String photopath) {
        this.photopath = photopath;
    }

    public String getFilename() {
        return filename;
    }

    public void setFilename(String filename) {
        this.filename = filename;
    }

    public Item getIditem() {
        return iditem;
    }

    public void setIditem(Item iditem) {
        this.iditem = iditem;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idphoto != null ? idphoto.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Photos)) {
            return false;
        }
        Photos other = (Photos) object;
        if ((this.idphoto == null && other.idphoto != null) || (this.idphoto != null && !this.idphoto.equals(other.idphoto))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.oneCommerce.entities.Photos[ idphoto=" + idphoto + " ]";
    }
    
}
